home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / tch_tpas.zip / TL01.TXT < prev    next >
Text File  |  1986-04-05  |  13KB  |  469 lines

  1. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 1 
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.                           TURBO-LESSONS
  16.  
  17.                      A TURBO Pascal Tutorial
  18.                           Version 1.01
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.                         by Lyle M. Faurot
  29.                            June 8, 1985
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.     Copyright (C), 1985 by Lyle Faurot.  All rights reserved.
  58.  
  59.           TURBO is a trademark of Borland International.
  60. î
  61. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 2
  62.  
  63.               T A B L E     O F     C O N T E N T S 
  64.  
  65.                                                          Page
  66.  
  67. Introduction . . . . . . . . . . . . . . . . . . . . . . .  4
  68. Distribution Notice  . . . . . . . . . . . . . . . . . . .  5
  69.  
  70. TURBO-LESSON 1: GETTING STARTED
  71.      Loading TURBO . . . . . . . . . . . . . . . . . . . .  5
  72.      Main Menu . . . . . . . . . . . . . . . . . . . . . .  5
  73. TURBO-LESSON 2: EDITING PROGRAMS
  74.      Starting an edit session  . . . . . . . . . . . . . . 10
  75.      Ending an edit session  . . . . . . . . . . . . . . . 11
  76.      Moving the cursor . . . . . . . . . . . . . . . . . . PROG2
  77.      Inserting/Replacing text  . . . . . . . . . . . . . . PROG2
  78.      Deleting text . . . . . . . . . . . . . . . . . . . . PROG2
  79.      Auto-tabbing  . . . . . . . . . . . . . . . . . . . . PROG2
  80. TURBO-LESSON 3: PROGRAM STRUCTURE
  81.      Program structure . . . . . . . . . . . . . . . . . . 12
  82.      Compiler Directive, $U+ . . . . . . . . . . . . . . . 13
  83.      WRITE and WRITELN statements  . . . . . . . . . . . . 13
  84.      Comments  . . . . . . . . . . . . . . . . . . . . . . 14
  85. TURBO-LESSON 4: DECLARATIONS, INPUT
  86.      DECLARATIONS part of program  . . . . . . . . . . . . 16
  87.      VAR declaration . . . . . . . . . . . . . . . . . . . 16
  88.      Input usint READLN statement  . . . . . . . . . . . . 17
  89.      Integer Variables . . . . . . . . . . . . . . . . . . 18
  90. TURBO-LESSON 5: INTEGER EXPRESSIONS
  91.      Assignment statements . . . . . . . . . . . . . . . . 20
  92.      Integer expressions . . . . . . . . . . . . . . . . . 21
  93.      Problems with expressions . . . . . . . . . . . . . . 23
  94. TURBO-LESSON 6: CONDITIONAL PROCESSING
  95.      Selection structures  . . . . . . . . . . . . . . . . 25
  96.      IF statement (One-way selection)  . . . . . . . . . . 26
  97.      IF statement (Two-way selection)  . . . . . . . . . . 27
  98. TURBO-LESSON 7: REPEAT STATEMENT
  99.      CHARacter variables . . . . . . . . . . . . . . . . . 28
  100.      BOOLEAN variables . . . . . . . . . . . . . . . . . . 29
  101.      REPEAT statement  . . . . . . . . . . . . . . . . . . 30
  102. TURBO-LESSON 8: CASE STATEMENT
  103.      Block statements  . . . . . . . . . . . . . . . . . . 32
  104.      CASE statement  . . . . . . . . . . . . . . . . . . . 34
  105. TURBO-LESSON 9: FOR STATEMENT
  106.      Print field width indicator, ":n" . . . . . . . . . . 36
  107.      FOR statement . . . . . . . . . . . . . . . . . . . . 37
  108. TURBO-LESSON 10: WHILE STATEMENT
  109.      CONSTant declaration  . . . . . . . . . . . . . . . . 38
  110.      WHILE statement . . . . . . . . . . . . . . . . . . . 39
  111.      Delay timing loop . . . . . . . . . . . . . . . . . . 41
  112. î
  113. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 3
  114.  
  115.  
  116.                   INTRODUCTION TO TURBO-LESSONS 
  117.  
  118.     When Borland International ran their first ads for TURBO 
  119. PASCAL my reaction was "You gotta be kidding - they can't do 
  120. that".  But, it seems they did!  I've been enjoying this 
  121. programming system ever since.  Apparently a great many other 
  122. programmers are either programming in TURBO or would like to 
  123. learn how.  TURBO-LESSONS were designed to meet that need.  
  124.  
  125.     Each TURBO-LESSON is a bite-size tutorial which introduces 
  126. one or more new concepts.  Each of the lessons are presented in 
  127. the same format which includes the OBJECTIVES of the lesson, and 
  128. the TUTORIAL portion of the lesson.  Most lessons direct you to 
  129. work with a sample program which is provided with these lessons.  
  130.  
  131.      Be sure you make a back-up copy of the programs - you will 
  132. be modifying and adding to the sample programs, and may want to 
  133. return to the original copy of a program.
  134.  
  135.      Sample programs are numbered to correspond to the lessons:
  136. PROG1 goes with TURBO-LESSON 1, PROG2, PROG2A go with TURBO-
  137. LESSON2, . . . 
  138.  
  139.     To begin, you should print the TURBO-LESSONS before loading 
  140. TURBO.  To help you get started, TURBO-LESSON 1 shows you how to 
  141. load TURBO and run a sample program.  
  142.  
  143.  
  144.              ****************************************
  145.              D I S T R I B U T I O N      N O T I C E 
  146.              ****************************************
  147.  
  148.  
  149. TURBO-LESSONS are being distributed as USER-SUPPORTED software. 
  150.  
  151. Suggested donation, $7.00, for this first set, lessons 1-10, may 
  152. be sent to:
  153.  
  154. Dr. Lyle Faurot
  155. 1904 18th Ave. South
  156. Moorhead, MN   56560
  157.  
  158.  
  159. COPYING BY ORGANIZATIONS
  160.  
  161. Clubs and other non-profit organizations may copy these lessons 
  162. for their members, with the following conditions:
  163.  
  164. 1.  No charge is made for TURBO-LESSONS, except a distribution 
  165. charge may be made to cover the price of the diskette.  Suggested 
  166. donation is to be made directly to the author of the lessons.
  167.  
  168. 2.  Club members are informed that TURBO-LESSONS are distributed 
  169. as user-supported software.
  170.  
  171. 3.  TURBO-LESSONS are distributed unmodified.
  172. î
  173. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 4
  174.  
  175.  
  176.                  TURBO-LESSON 1: GETTING STARTED         
  177.  
  178.  
  179. OBJECTIVES - In this lesson you will learn about:
  180.  
  181. 1.  Loading TURBO
  182. 2.  Using the Main Menu to Load, Compile, and Run a program
  183.  
  184.  
  185. INTRODUCTION
  186.  
  187. TURBO-LESSONS were written with the following goals in mind:
  188.  
  189.     -- Present the concepts of Pascal and the TURBO Pascal
  190.        implementation in bite-size chunks (called lessons).
  191.  
  192.     -- Provide one or more sample Pascal programs with each 
  193.        lesson.   Programming examples are often more helpful
  194.        than eloquent discussion in learning to program.
  195.  
  196.     -- Structure the lessons in a parallel format to make them
  197.        more useful later as a reference.  The OBJECTIVE section
  198.        at the beginning of each lesson will help you locate
  199.        a topic later.
  200.  
  201.     -- Structure the lessons in an Action format.  If you are
  202.        like me, you probably learn programming best by doing.
  203.        
  204.     -- Mark the points where some action is suggested.  This 
  205.        should allow for differences in learning styles.  The 
  206.        action points are marked as follows:
  207.  
  208.        ##### DO:
  209.  
  210.        For those who like to hit the high points as fast as 
  211.        possible, these action markers will point the way.
  212.  
  213.    
  214. Now, without further delay, on with the show!       
  215. î
  216. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 5
  217.       
  218.  
  219. 1.  Loading TURBO.
  220.  
  221. To get started, put a diskette with TURBO PASCAL in your default 
  222. drive.  
  223.  
  224. ##### DO:
  225.  
  226. Type TURBO and enter.  
  227.  
  228. A message will appear:
  229.  
  230.     Include error messages (Y/N)?
  231.  
  232. You should answer Y to provide on-screen error messages.  The 
  233. Main Menu will appear at this point.  
  234.  
  235.  
  236. 2.  Using the Main Menu to Load, Compile, and Run a program.  
  237.  
  238. The menu should appear with one letter of each option 
  239. highlighted.  
  240.  
  241. ##### DO:
  242.  
  243. Adjust the brightness level of your screen.  You may need to 
  244. adjust both brightness and contrast to make the key letters stand 
  245. out at a comfortable level.
  246.  
  247. The main menu is the starting point for most of the things you 
  248. will do with TURBO.  Some of the options will be discussed in 
  249. more detail later, but for now, you should learn to get back to 
  250. the main menu from each of the options.  
  251.  
  252. ******************** Logged drive:
  253.  
  254. The Logged drive is where your Work files are stored.  This 
  255. option is used to change your logged drive.  
  256.  
  257. ##### DO:
  258.  
  259. Type L.        
  260.  
  261. Computer responds: "New drive:"    
  262.  
  263. Type B (or another drive) and enter.
  264.  
  265. Look at the top of the screen.  Did the logged drive change?  
  266.  
  267. Now, depress the space bar.  It appeared that no change had been 
  268. made until the menu screen was redisplayed.  
  269. î
  270. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 6
  271.  
  272.  
  273. ******* NOTE:  SOME OF THE OPTIONS DO NOT UPDATE THE MENU SCREEN.  
  274. YOU CAN REDISPLAY THE MENU WITH THE SPACE BAR OR ENTER KEY.  
  275.  
  276. You could have responded to the "New drive:" message by 
  277. depressing the enter key without entering another drive 
  278. designator.  The enter key by itself is used to escape from this 
  279. option without making any changes.  
  280.  
  281. The first four options at the top of the menu, L, A, W, and M all 
  282. use the enter key alone as an escape key.  
  283.  
  284.  
  285. ******************** Active directory: \                 
  286.  
  287. Use the A option to change the Active subdirectory if your logged 
  288. drive is a hard disk.
  289.  
  290. ##### DO:
  291.  
  292. Type A.           
  293.  
  294. Computer responds: "New directory:"   
  295.  
  296. Type subdirectory name and enter or just enter for no change.
  297.  
  298.    
  299. ******************** Work file:
  300.  
  301. This is where you name your work file.  The work file will hold 
  302. the PASCAL program you are writing or editing.
  303.  
  304. ##### DO:
  305.  
  306. Type W.           
  307.  
  308. Computer responds: "Work file name:"  
  309.  
  310. Type PROG1 and enter. (If you get the message, "New File", 
  311. PROG1.PAS was not found on your logged drive. Your sample 
  312. programs, including PROG1, should be on the logged drive).  
  313.  
  314.  
  315. ******************** Main file:
  316.  
  317. Ignore this option for now.  If you just can't resist typing M at 
  318. this point, remember that Enter is the escape key for this 
  319. option.  
  320. î
  321. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 7
  322.  
  323.  
  324. ******************** Run
  325.  
  326. This option is used to execute a program, compiling it first, if 
  327. necessary.
  328.  
  329. ##### DO:
  330.  
  331. Type R.    
  332.  
  333. The program in your work file, PROG1, is compiled and executed.  
  334.  
  335. Type R again.
  336.  
  337. Note that the program runs again without compiling.  The Run 
  338. option will only compile if changes have been made in the program 
  339. since the previous compile.  
  340.  
  341. Depress the space bar to get the menu back.
  342.  
  343.                                            
  344. ******************** Compile
  345.  
  346. The program may be compiled without executing by using the C 
  347. option.  You may want to compile to see an error message without 
  348. running the program.  Or you may be compiling a COM file, which 
  349. cannot be executed until you exit TURBO to DOS.
  350.  
  351. ##### DO:
  352.  
  353. Type C.
  354.  
  355. The program compiles but doesn't run.  Use this option when you 
  356. want to compile without executing the program immediately.  
  357.  
  358.  
  359. ******************** Edit                                
  360.  
  361. The editor is used to enter a new program or change a program.  
  362. Another lesson is devoted to editing.  For now, you should find 
  363. out how to get back to the menu from this option.  
  364.  
  365. ##### DO:
  366.  
  367. Type E.
  368.  
  369. The program, PROG1, appears on the screen, ready to edit.
  370. Use the Ctrl-K, Ctrl-D sequence to return to the main menu.
  371. î
  372. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 8
  373.  
  374.  
  375. ##### DO:
  376.  
  377. Type Ctrl-K, Ctrl-D. (While depressing the Ctrl key, type K 
  378.                       followed by D.)   
  379.  
  380. The main menu reappears.  Note that there is no way to abandon 
  381. the edited file in memory.  This is not so bad since the edited 
  382. copy of the program in memory is not automatically saved to disk.  
  383. You can use the Work file option to get another copy of the 
  384. program from disk.  
  385.  
  386.  
  387. ******************** Save 
  388.  
  389. Use this option to copy your current work file from memory to 
  390. disk.
  391.  
  392. ##### DO:
  393.  
  394. Type S.
  395.  
  396. The program, PROG1, is saved to the disk on the drive designated 
  397. when you named this work file.  Since the work file is not 
  398. automatically saved to disk, TURBO reminds you to save the file 
  399. before any option which would destroy the copy of the file in 
  400. memory.  
  401.  
  402. NOTE: REMEMBER, IT IS UP TO YOU TO SAVE YOUR WORK FILE.  IT'S A 
  403. GOOD IDEA TO SAVE IT FREQUENTLY, IN CASE SOMETHING SUCH AS AN 
  404. INFINITE LOOP FORCES YOU TO RE-BOOT (IN WHICH CASE YOUR WORK FILE 
  405. IN MEMORY WOULD BE FOREVER GONE!)
  406.  
  407.  
  408. ******************** Dir 
  409.  
  410. The D option works similar to DIR in DOS.
  411.  
  412. ##### DO:
  413.  
  414. Type D.
  415.  
  416. Computer responds: "Dir mask:"
  417.  
  418. Depress the Enter key to get a directory of the logged drive or 
  419. use drive designator to get a directory of another drive.  You 
  420. can use the wildcards, "*" and "?".
  421. î
  422. TURBO-LESSONS - A Pascal Tutorial        Version 1.01    Page 9
  423.  
  424.  
  425. ******************** compiler Options                     
  426.  
  427. These will be discussed later when they are needed.  Try the O 
  428. option now to be sure you know how to get back to the menu.  
  429.  
  430. ##### DO:
  431.  
  432. Type O.
  433.  
  434. The compiler Options menu is displayed.  
  435.  
  436. You can choose the various compiler options by typing the 
  437. corresponding letter.  
  438.  
  439. ##### DO:
  440.  
  441. Type C.
  442.  
  443. Notice the arrow moved to a different option.
  444.  
  445. Type H.
  446.  
  447. Type M.
  448.  
  449. Be sure to leave the compiler option set to M, memory before 
  450. returning to the main menu.  
  451.  
  452. Type Q.
  453.  
  454. The main menu reappears.
  455.  
  456.  
  457. ******************** Quit 
  458.  
  459. This option returns you to DOS.  When you are through 
  460. experimenting with the menu options, 
  461.  
  462. ##### DO:
  463.  
  464. Type Q.
  465.  
  466. You will be prompted to save your work file if it has been 
  467. modified since you last saved it.  The prompt of the default 
  468. drive will be displayed.
  469. î